package com.shy.pet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shy.pet.common.R;
import com.shy.pet.entity.Users;
import com.shy.pet.mapper.UsersMapper;
import com.shy.pet.service.UsersService;
import jakarta.servlet.http.HttpSession;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {

    //查询个人中心数据
    @Override
    public R<Users> getperson(HttpSession session) {
        int usersid = (int) session.getAttribute("users");
        Users users = getOne(new QueryWrapper<Users>().eq("user_id", usersid));
        return R.success(users);
    }

    @Override
    public R<String> update(Users users, HttpSession session) {
        int usersid = (int) session.getAttribute("users");
        users.setUserId(usersid);
        updateById(users);
        return R.success("修改成功");
    }
}
